package com.ma.old;

import java.util.Arrays;

public class strStr {
    public static int strStr(String haystack, String needle) {
        int m = haystack.length(), n = needle.length();
        if (n == 0) return 0;
        char[] s1 = haystack.toCharArray(), s2 = needle.toCharArray();
        for (int i = 0; i <= m - n; i++) {
            int a = i, b = 0;
            while (b < n && s1[a] == s2[b]) {
                a++;
                b++;
            }
            if (b == n) return i;
        }

        return -1;


    }

    public static void main(String[] args) {
        String s1 = "hellolla";
        String s2 = "lla";
        System.out.println(strStr(s1, s2));
    }

}
